package com.gzy.action;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzy.entity.Center;
import com.gzy.service.ICenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 郭梓炀
 * @since 2022-05-03
 */
@RequestMapping("/center")
@RestController
public class CenterController {
    @Autowired
    ICenterService centerService;

    /**
     * 列表查询
     * @param min
     * @param max
     * @param pageNum
     * @return
     */
    @RequestMapping("getList")
    public ResponseEntity getList(@RequestParam(defaultValue = "0")int min,
                                  @RequestParam(defaultValue = "0")int max,
                                  @RequestParam(defaultValue = "1")int pageNum){
        Page<Center> page = centerService.getList(min,max,pageNum);
        return new ResponseEntity(page, HttpStatus.OK);
    }

    @RequestMapping("changeWare")
    public ResponseEntity changeWare(@RequestBody Center center){
        boolean b = centerService.updateById(center);
        return new ResponseEntity(b, HttpStatus.OK);
    }

    @RequestMapping("changeOut")
    public ResponseEntity changeOut(@RequestBody Center center){
        boolean b = centerService.updateOut(center);
        return new ResponseEntity(b, HttpStatus.OK);
    }

    @RequestMapping("changeIn")
    public ResponseEntity changeIn(@RequestBody Center center){
        boolean b = centerService.changeIn(center);

        return new ResponseEntity(b, HttpStatus.OK);
    }

}
